gdk: Remove gdk_utf8_to_string_target()
authorBenjamin Otte <otte@redhat.com>
Sat, 22 Feb 2020 17:33:20 +0000 (18:33 +0100)
committerBenjamin Otte <otte@redhat.com>
Sun, 23 Feb 2020 00:59:00 +0000 (01:59 +0100)
Only keep the X11 version around in the backend.

21 files changed:
docs/reference/gdk/gdk4-sections.txt
gdk/broadway/gdkdisplay-broadway.c
gdk/broadway/gdkprivate-broadway.h
gdk/broadway/gdkselection-broadway.c
gdk/gdkdisplayprivate.h
gdk/gdkproperty.h
gdk/gdkselection.c
gdk/quartz/gdkdisplay-quartz.c
gdk/quartz/gdkdisplay-quartz.h
gdk/quartz/gdkselection-quartz.c
gdk/wayland/gdkdisplay-wayland.c
gdk/wayland/gdkprivate-wayland.h
gdk/wayland/gdkselection-wayland.c
gdk/win32/gdkclipdrop-win32.c
gdk/win32/gdkdisplay-win32.c
gdk/win32/gdkprivate-win32.h
gdk/x11/gdkdisplay-x11.c
gdk/x11/gdkprivate-x11.h
gdk/x11/gdkselection-x11.c
gdk/x11/gdksurface-x11.c
gdk/x11/gdktextlistconverter-x11.c

index b6f297238b1404fd5370488675c532a0b5236d51..c2702348f45a25972a9498a2fe2122fdd420edd3 100644 (file)
@@ -352,7 +352,6 @@ gdk_content_formats_builder_get_type
 <FILE>properties</FILE>
 GdkAtom
 gdk_text_property_to_utf8_list_for_display
-gdk_utf8_to_string_target
 </SECTION>
 
 <SECTION>
index ba6dc7a9a737895ca8e6b5e7cc674dae0cd05b4a..f35d3f56ef93e16c4ef4a8026b71c5fd25c57757 100644 (file)
@@ -429,7 +429,6 @@ gdk_broadway_display_class_init (GdkBroadwayDisplayClass * class)
   display_class->create_surface = _gdk_broadway_display_create_surface;
   display_class->get_keymap = _gdk_broadway_display_get_keymap;
   display_class->text_property_to_utf8_list = _gdk_broadway_display_text_property_to_utf8_list;
-  display_class->utf8_to_string_target = _gdk_broadway_display_utf8_to_string_target;
 
   display_class->get_n_monitors = gdk_broadway_display_get_n_monitors;
   display_class->get_monitor = gdk_broadway_display_get_monitor;
index f414d3d79c81d8eeacc05da6ab5a301852aea2d5..8e8d7813337472bdcd2116f0314a656de20fc4c6 100644 (file)
@@ -119,8 +119,6 @@ gint _gdk_broadway_display_text_property_to_utf8_list (GdkDisplay    *display,
                                                        const guchar  *text,
                                                        gint           length,
                                                        gchar       ***list);
-gchar *_gdk_broadway_display_utf8_to_string_target (GdkDisplay  *display,
-                                                    const gchar *str);
 GdkKeymap* _gdk_broadway_display_get_keymap (GdkDisplay *display);
 void _gdk_broadway_display_consume_all_input (GdkDisplay *display);
 BroadwayInputMsg * _gdk_broadway_display_block_for_input (GdkDisplay *display,
index f9c8b389a23dd4380407ae1db525ec792600cc6a..6eb82f1e5c8faca2d50fe2b1380be6e3b1bcaf1f 100644 (file)
@@ -135,9 +135,3 @@ _gdk_broadway_display_text_property_to_utf8_list (GdkDisplay    *display,
   return 0;
 }
 
-gchar *
-_gdk_broadway_display_utf8_to_string_target (GdkDisplay  *display,
-                                            const gchar *str)
-{
-  return g_strdup (str);
-}
index 2026daca7aff7ecdd2b71974387a3f49a98967d7..f20f79855e7cd295fa63cf77217120326d5175df 100644 (file)
@@ -156,8 +156,6 @@ struct _GdkDisplayClass
                                                         const guchar   *text,
                                                         gint            length,
                                                         gchar        ***list);
-  gchar *                (*utf8_to_string_target)      (GdkDisplay     *display,
-                                                        const gchar    *text);
 
   gboolean               (*make_gl_context_current)    (GdkDisplay        *display,
                                                         GdkGLContext      *context);
index a54adc27750ba974f16a1d7c800a8590bacb0aee..0ff5139a03cd34352f1b61bf8a143aaf7f3a0d9c 100644 (file)
@@ -43,9 +43,6 @@ gint   gdk_text_property_to_utf8_list_for_display (GdkDisplay     *display,
                                                    gint            length,
                                                    gchar        ***list);
 
-GDK_AVAILABLE_IN_ALL
-gchar *gdk_utf8_to_string_target                  (const gchar    *str);
-
 G_END_DECLS
 
 #endif /* __GDK_PROPERTY_H__ */
index 1929b8ed2e41e5d092a85f19454fd335bc0c4d57..6905110e69dca752b8e3969079a1a716c8b35d2e 100644 (file)
@@ -61,25 +61,3 @@ gdk_text_property_to_utf8_list_for_display (GdkDisplay     *display,
            ->text_property_to_utf8_list (display, encoding, format, text, length, list);
 }
 
-/**
- * gdk_utf8_to_string_target:
- * @str: a UTF-8 string
- *
- * Converts a UTF-8 string into the best possible representation
- * as a STRING. The representation of characters not in STRING
- * is not specified; it may be as pseudo-escape sequences
- * \x{ABCD}, or it may be in some other form of approximation.
- *
- * Returns: (nullable): the newly-allocated string, or %NULL if the
- *          conversion failed. (It should not fail for any properly
- *          formed UTF-8 string unless system limits like memory or
- *          file descriptors are exceeded.)
- **/
-gchar *
-gdk_utf8_to_string_target (const gchar *str)
-{
-  GdkDisplay *display = gdk_display_get_default ();
-
-  return GDK_DISPLAY_GET_CLASS (display)->utf8_to_string_target (display, str);
-}
-
index 7ab78f09d6b4b379c00d2da19db0a2f0a23dbddd..bf165e252cade3f90a71e2a7955c164dd3478762 100644 (file)
@@ -231,7 +231,6 @@ gdk_quartz_display_class_init (GdkQuartzDisplayClass *class)
   display_class->create_surface_impl = _gdk_quartz_display_create_surface_impl;
   display_class->get_keymap = _gdk_quartz_display_get_keymap;
   display_class->text_property_to_utf8_list = _gdk_quartz_display_text_property_to_utf8_list;
-  display_class->utf8_to_string_target = _gdk_quartz_display_utf8_to_string_target;
   display_class->get_n_monitors = gdk_quartz_display_get_n_monitors;
   display_class->get_monitor = gdk_quartz_display_get_monitor;
   display_class->get_setting = gdk_quartz_display_get_setting;
index 33e1c67ce66c7a0d7c158c4390d80c1d6fb390da..8e5543be4ca7fa97758750f84dbbf6c06ccfa1cc 100644 (file)
@@ -76,8 +76,6 @@ gint        _gdk_quartz_display_text_property_to_utf8_list (GdkDisplay     *disp
                                                             const guchar   *text,
                                                             gint            length,
                                                             gchar        ***list);
-gchar *     _gdk_quartz_display_utf8_to_string_target      (GdkDisplay     *displayt,
-                                                            const gchar    *str);
 
 G_END_DECLS
 
index 6e177fdce059b6416cbfdeb1f6c43dec641f484a..e79ca91e4579d96e03725b0f1d0579f739960f12 100644 (file)
 #include "gdkproperty.h"
 #include "gdkquartz.h"
 
-gchar *
-_gdk_quartz_display_utf8_to_string_target (GdkDisplay  *display,
-                                           const gchar *str)
-{
-  /* FIXME: Implement */
-  return NULL;
-}
-
 static gint
 make_list (const gchar  *text,
           gint          length,
index 8ffc2d048ee2f44134601e2160a81de194c038ac..199468e03e723348c9657c62128b6678f210a80e 100644 (file)
@@ -1031,7 +1031,6 @@ gdk_wayland_display_class_init (GdkWaylandDisplayClass *class)
   display_class->create_surface = _gdk_wayland_display_create_surface;
   display_class->get_keymap = _gdk_wayland_display_get_keymap;
   display_class->text_property_to_utf8_list = _gdk_wayland_display_text_property_to_utf8_list;
-  display_class->utf8_to_string_target = _gdk_wayland_display_utf8_to_string_target;
 
   display_class->make_gl_context_current = gdk_wayland_display_make_gl_context_current;
 
index 396fa15ad265effa5163631987580e3d5f5fbf9f..830e185029d8e94115370ee7aa29837d2844db88 100644 (file)
@@ -133,8 +133,6 @@ gint        _gdk_wayland_display_text_property_to_utf8_list (GdkDisplay    *disp
                                                              const guchar  *text,
                                                              gint           length,
                                                              gchar       ***list);
-gchar *     _gdk_wayland_display_utf8_to_string_target (GdkDisplay  *display,
-                                                        const gchar *str);
 
 void        _gdk_wayland_display_create_seat    (GdkWaylandDisplay *display,
                                                  guint32                  id,
index 9683a5a8ed03b069fb5de17e35b5f937d462a178..8f02cdd123fc98100c32d3f9cb8ed40682a9cf7e 100644 (file)
@@ -73,68 +73,3 @@ _gdk_wayland_display_text_property_to_utf8_list (GdkDisplay    *display,
   return nitems;
 }
 
-/* This function has been copied straight from the x11 backend */
-static gchar *
-sanitize_utf8 (const gchar *src,
-               gboolean return_latin1)
-{
-  gint len = strlen (src);
-  GString *result = g_string_sized_new (len);
-  const gchar *p = src;
-
-  while (*p)
-    {
-      if (*p == '\r')
-        {
-          p++;
-          if (*p == '\n')
-            p++;
-
-          g_string_append_c (result, '\n');
-        }
-      else
-        {
-          gunichar ch = g_utf8_get_char (p);
-
-          if (!((ch < 0x20 && ch != '\t' && ch != '\n') || (ch >= 0x7f && ch < 0xa0)))
-            {
-              if (return_latin1)
-                {
-                  if (ch <= 0xff)
-                    g_string_append_c (result, ch);
-                  else
-                    g_string_append_printf (result,
-                                            ch < 0x10000 ? "\\u%04x" : "\\U%08x",
-                                            ch);
-                }
-              else
-                {
-                  char buf[7];
-                  gint buflen;
-
-                  buflen = g_unichar_to_utf8 (ch, buf);
-                  g_string_append_len (result, buf, buflen);
-                }
-            }
-
-          p = g_utf8_next_char (p);
-        }
-    }
-
-  return g_string_free (result, FALSE);
-}
-
-gchar *
-_gdk_wayland_display_utf8_to_string_target (GdkDisplay  *display,
-                                            const gchar *str)
-{
-  /* This is mainly needed when interfacing with old clients through
-   * Xwayland, the STRING target could be used, and passed as-is
-   * by the compositor.
-   *
-   * There's already some handling of this atom (aka "mimetype" in
-   * this backend) in common code, so we end up in this vfunc.
-   */
-  return sanitize_utf8 (str, TRUE);
-}
-
index e45fc42e9c5ef5accf1d94ee1c9381924ad9acaa..cd40dedaf34fc737493d04abc734bcfd358dd3ad 100644 (file)
@@ -2782,13 +2782,6 @@ _gdk_win32_display_text_property_to_utf8_list (GdkDisplay    *display,
     }
 }
 
-gchar *
-_gdk_win32_display_utf8_to_string_target (GdkDisplay *display,
-                                         const gchar *str)
-{
-  return g_strdup (str);
-}
-
 gint
 _gdk_win32_add_contentformat_to_pairs (const gchar *contentformat,
                                        GArray      *array)
index 8ccefcf539a1053e42f241d2764db85c9b615fd1..7f9785b239c1fe7444977ade983554ebc50d51db 100644 (file)
@@ -1119,7 +1119,6 @@ gdk_win32_display_class_init (GdkWin32DisplayClass *klass)
 
   display_class->get_keymap = _gdk_win32_display_get_keymap;
   display_class->text_property_to_utf8_list = _gdk_win32_display_text_property_to_utf8_list;
-  display_class->utf8_to_string_target = _gdk_win32_display_utf8_to_string_target;
   display_class->make_gl_context_current = _gdk_win32_display_make_gl_context_current;
 
   display_class->get_n_monitors = gdk_win32_display_get_n_monitors;
index d3377bbf345cf5e2b0d0c872330fdadbf45fad75..e4821d71b15db55ef9b2ddb9fed2069283d02df3 100644 (file)
@@ -401,7 +401,6 @@ gint      _gdk_win32_display_text_property_to_utf8_list (GdkDisplay    *display,
                                                          const guchar  *text,
                                                          gint           length,
                                                          gchar       ***list);
-gchar     *_gdk_win32_display_utf8_to_string_target (GdkDisplay *display, const gchar *str);
 
 gboolean   _gdk_win32_keymap_has_altgr           (GdkWin32Keymap *keymap);
 guint8     _gdk_win32_keymap_get_active_group    (GdkWin32Keymap *keymap);
index 5a863f9000bbdcb1c1f3cae68643fd93bba1501a..7147ad6a2358be9da05dccf621031bb4154886f4 100644 (file)
@@ -3053,7 +3053,6 @@ gdk_x11_display_class_init (GdkX11DisplayClass * class)
   display_class->create_surface = _gdk_x11_display_create_surface;
   display_class->get_keymap = gdk_x11_display_get_keymap;
   display_class->text_property_to_utf8_list = _gdk_x11_display_text_property_to_utf8_list;
-  display_class->utf8_to_string_target = _gdk_x11_display_utf8_to_string_target;
 
   display_class->make_gl_context_current = gdk_x11_display_make_gl_context_current;
 
index 69a1248b8aa68709305d2ea8681f346f9f7ba515..5bd6bb3e75253b21f3570393f68b6dc4754360d8 100644 (file)
@@ -125,8 +125,8 @@ gint        _gdk_x11_display_text_property_to_utf8_list (GdkDisplay     *display
                                                          const guchar   *text,
                                                          gint            length,
                                                          gchar        ***list);
-gchar *     _gdk_x11_display_utf8_to_string_target      (GdkDisplay     *displayt,
-                                                         const gchar    *str);
+char *      gdk_x11_utf8_to_string_target               (const char     *utf8_str,
+                                                         gboolean        return_latin1);
 
 void _gdk_x11_device_check_extension_events   (GdkDevice  *device);
 
index 7f34dfce843c4c365d3b3c613cbc8eed17797173..169ba661fa7258feeb50aff4c562b6b0e3f0e3b9 100644 (file)
@@ -325,70 +325,6 @@ gdk_x11_display_string_to_compound_text (GdkDisplay  *display,
   return res;
 }
 
-/* The specifications for COMPOUND_TEXT and STRING specify that C0 and
- * C1 are not allowed except for \n and \t, however the X conversions
- * routines for COMPOUND_TEXT only enforce this in one direction,
- * causing cut-and-paste of \r and \r\n separated text to fail.
- * This routine strips out all non-allowed C0 and C1 characters
- * from the input string and also canonicalizes \r, and \r\n to \n
- */
-static gchar *
-sanitize_utf8 (const gchar *src,
-               gboolean return_latin1)
-{
-  gint len = strlen (src);
-  GString *result = g_string_sized_new (len);
-  const gchar *p = src;
-
-  while (*p)
-    {
-      if (*p == '\r')
-        {
-          p++;
-          if (*p == '\n')
-            p++;
-
-          g_string_append_c (result, '\n');
-        }
-      else
-        {
-          gunichar ch = g_utf8_get_char (p);
-
-          if (!((ch < 0x20 && ch != '\t' && ch != '\n') || (ch >= 0x7f && ch < 0xa0)))
-            {
-              if (return_latin1)
-                {
-                  if (ch <= 0xff)
-                    g_string_append_c (result, ch);
-                  else
-                    g_string_append_printf (result,
-                                            ch < 0x10000 ? "\\u%04x" : "\\U%08x",
-                                            ch);
-                }
-              else
-                {
-                  char buf[7];
-                  gint buflen;
-
-                  buflen = g_unichar_to_utf8 (ch, buf);
-                  g_string_append_len (result, buf, buflen);
-                }
-            }
-
-          p = g_utf8_next_char (p);
-        }
-    }
-
-  return g_string_free (result, FALSE);
-}
-
-gchar *
-_gdk_x11_display_utf8_to_string_target (GdkDisplay  *display,
-                                        const gchar *str)
-{
-  return sanitize_utf8 (str, TRUE);
-}
-
 /**
  * gdk_x11_display_utf8_to_compound_text:
  * @display: (type GdkX11Display): a #GdkDisplay
@@ -423,7 +359,7 @@ gdk_x11_display_utf8_to_compound_text (GdkDisplay  *display,
 
   need_conversion = !g_get_charset (&charset);
 
-  tmp_str = sanitize_utf8 (str, FALSE);
+  tmp_str = gdk_x11_utf8_to_string_target (str, FALSE);
 
   if (need_conversion)
     {
index 699bcf2864aa4da59cdc09a30d106a5032d29657..f023e09473f9bd2de079b74f7304f6ee031a55f8 100644 (file)
@@ -2235,7 +2235,7 @@ set_text_property (GdkDisplay  *display,
   if (utf8_is_latin1 (utf8_str))
     {
       prop_type = XA_STRING;
-      prop_text = _gdk_x11_display_utf8_to_string_target (display, utf8_str);
+      prop_text = gdk_x11_utf8_to_string_target (utf8_str, TRUE);
       prop_length = prop_text ? strlen (prop_text) : 0;
       prop_format = 8;
       is_compound_text = FALSE;
index 38c7df9a71c674f28ac6d357134eda84a6e4f40d..88c4a5310f689e8c5bdd6f82f412f5ddb652ac6f 100644 (file)
@@ -121,6 +121,63 @@ gdk_x11_text_list_converter_decode (GdkX11TextListConverter *conv,
     }
 }
 
+/* The specifications for COMPOUND_TEXT and STRING specify that C0 and
+ * C1 are not allowed except for \n and \t, however the X conversions
+ * routines for COMPOUND_TEXT only enforce this in one direction,
+ * causing cut-and-paste of \r and \r\n separated text to fail.
+ * This routine strips out all non-allowed C0 and C1 characters
+ * from the input string and also canonicalizes \r, and \r\n to \n
+ */
+char *
+gdk_x11_utf8_to_string_target (const char *utf8_str,
+                               gboolean    return_latin1)
+{
+  gint len = strlen (utf8_str);
+  GString *result = g_string_sized_new (len);
+  const gchar *p = utf8_str;
+
+  while (*p)
+    {
+      if (*p == '\r')
+        {
+          p++;
+          if (*p == '\n')
+            p++;
+
+          g_string_append_c (result, '\n');
+        }
+      else
+        {
+          gunichar ch = g_utf8_get_char (p);
+
+          if (!((ch < 0x20 && ch != '\t' && ch != '\n') || (ch >= 0x7f && ch < 0xa0)))
+            {
+              if (return_latin1)
+                {
+                  if (ch <= 0xff)
+                    g_string_append_c (result, ch);
+                  else
+                    g_string_append_printf (result,
+                                            ch < 0x10000 ? "\\u%04x" : "\\U%08x",
+                                            ch);
+                }
+              else
+                {
+                  char buf[7];
+                  gint buflen;
+
+                  buflen = g_unichar_to_utf8 (ch, buf);
+                  g_string_append_len (result, buf, buflen);
+                }
+            }
+
+          p = g_utf8_next_char (p);
+        }
+    }
+
+  return g_string_free (result, FALSE);
+}
+
 static GConverterResult
 gdk_x11_text_list_converter_encode (GdkX11TextListConverter *conv,
                                     const void              *inbuf,
@@ -146,7 +203,7 @@ gdk_x11_text_list_converter_encode (GdkX11TextListConverter *conv,
       gchar *tmp, *latin1;
 
       tmp = g_strndup (inbuf, inbuf_size);
-      latin1 = gdk_utf8_to_string_target (tmp);
+      latin1 = gdk_x11_utf8_to_string_target (tmp, TRUE);
       g_free (tmp);
       if (latin1)
         {